package com.k7k7.cserver;

import com.k7k7.client.UserClientThread;
import com.k7k7.cserver.config.ControlServerConfig;
import com.k7k7.cserver.sceneclient.SceneServerThread;
import com.k7k7.cserver.client.ClientC;
import org.apache.log4j.Logger;

/**
 * Created by IntelliJ IDEA.
 * User: Administrator
 * Date: 2009-4-21
 * Time: 16:54:18
 */
public class ControlServer {
	public static Logger log = Logger.getLogger("ControlServer");

	public ControlServer(int clientPort, int sceneServerPort) {
		UserClientThread t1;
		try {
			t1 = new UserClientThread(clientPort, ClientC.class);
		} catch (Exception e) {
			log.fatal("总控服务器建立用户服务错误!");
			log.info(e.getStackTrace());
			return;
		}
		t1.start();
		SceneServerThread sst = null;
		try {
			sst = new SceneServerThread(sceneServerPort);
			sst.start();
		} catch (Exception e) {
			t1.interrupt();
			if (sst != null) {
				sst.interrupt();
			}
			log.fatal("总控服务器建立场景服务错误!");
			log.info(e.getStackTrace());
		}

	}

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		new ControlServer(ControlServerConfig.clientPort, ControlServerConfig.sceneServerPort);
	}

}
